#!/bin/bash

# Copyright (c) 2024 Huawei Device Co., Ltd.
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#     http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

DIR=$PWD

function start_compile() {
    export PATH="$DIR/depot_tools:$PATH"
    export TOOL_HOME=$DIR/command-line-tools
    export DEVECO_SDK_HOME=$TOOL_HOME/sdk
    export HOS_SDK_HOME=$TOOL_HOME/sdk
    export NODE_HOME=$DIR/flutter_env/node-v16.14.2-linux-x64
    export PATH=$TOOL_HOME/ohpm/bin:$TOOL_HOME/hvigor/bin:$NODE_HOME/bin:$PATH

    echo "--> Starting build flutter_engine"
    python3 src/flutter/attachment/scripts/ohos.py -n config compile -t debug

    if [ $? -ne 0 ]
    then
        echo "build flutter_engine failed!!"
        return 1
    fi
    echo "--> End build flutter_engine"
}

start_compile $@

exit $?

#eof
